package com.mzba.place.utils;

import android.app.Service;

import com.mzba.place.BasicActivity;
import com.mzba.place.PusherService;

/**
 * 
 * @author 06peng
 *
 */
public class UICore {

	private static UICore ins = new UICore();
	
	private boolean isMainActivityExist;
	private PusherService pusherService;
	
	public boolean isMainActivityExist() {
		return isMainActivityExist;
	}

	public void setMainActivityExist(boolean isMainActivityExist) {
		this.isMainActivityExist = isMainActivityExist;
	}
	

	public PusherService getPusherService() {
		return pusherService;
	}

	public void setPusherService(PusherService pusherService) {
		this.pusherService = pusherService;
	}

	private UICore() {
		
	}

	public static UICore getInstance() {
		if (ins == null) {
			ins = new UICore();
		}
		return ins;
	}
	
	/**
	 * 执行异步加载的任务
	 * @param basicUIEvent
	 * @param context
	 * @param CommandID
	 * @param obj 
	 * @param showDialog 
	 */
	public static void eventTask(BasicUIEvent basicUIEvent, BasicActivity context, int CommandID, Object obj, boolean showDialog) {
		try {
			CommandTaskEvent commandTask = new CommandTaskEvent(basicUIEvent, context, showDialog);
			commandTask.execute((new Object[] { CommandID + "", obj }));
		} catch (Exception e) {
			e.printStackTrace();
			System.out.println("cancel:  success!!");
			if (context != null) {
				context.destroyDialog();
			}
		}
	}

	public static void eventTask(BasicUIEvent basicUIEvent, Service service, int CommandID, Object obj) {
		try {
			CommandTaskEvent commandTask = new CommandTaskEvent(basicUIEvent, service);
			commandTask.execute((new Object[] { CommandID + "", obj }));
		} catch (Exception e) {
			e.printStackTrace();
			System.out.println("cancel:  success!!");
		}
	}
	
}
